const Mock = require("mockjs");

const data = Mock.mock({
  "list|150-200": [
    {
      name: "@cname",
      shijian: "2020-12-12 12:00",
      title: "@ctitle(11)",
      "img|1": [
        "https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3",
        "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2202780618,895893289&fm=26&gp=0.jpg",
        "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=360400461,2955275651&fm=26&gp=0.jpg",
        "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1709216491,2536617744&fm=26&gp=0.jpg",
        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3036316726,676055399&fm=26&gp=0.jpg",
        "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3623279689,206753714&fm=26&gp=0.jpg"
      ],
      "statflag|1": [true, false],
      flag: true,
      id: "@id",
      gknum: 134,
      gznum: 33,
      dznum: 57,
      xdnum: 12,
      "fenxi|5": [
        {
          "id|1-100": 1,
          img:
            "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3623279689,206753714&fm=26&gp=0.jpg",
          title:
            "鸭鸭（YAYA）羽绒服男短款加厚2020新款大鹅绒保暖冬季加厚中年男士外套 l橘色-男 190/92A",
          "price|100-300": 1,
          guige: "http//：www.axcube.cn/goods/id=10980",
          "cishu|1000-10000": 1,
          "xiadan|100-1000": 1
        }
      ]
    }
  ]
});

module.exports = [
  {
    url: "/vue-element-admin/liveList",
    type: "post",
    response: res => {
      const { pageIndex, pageSize, flagqqq } = res.body;
      // console.log(flagqqq === true, flagqqq, "sddd");
      // console.log("res", res.body, pageIndex, pageSize);
      if (flagqqq === -1) {
        const list = data.list.slice(
          (pageIndex - 1) * pageSize,
          pageSize * pageIndex
        );
        return {
          code: 20000,
          data: list,
          total: data.list.length
        };
      } else if (flagqqq === true) {
        const result = data.list.filter(item => item.statflag === false);
        console.log(result.length, "weqweqw");
        const list = result.slice(
          (pageIndex - 1) * pageSize,
          pageSize * pageIndex
        );
        return {
          code: 20000,
          data: list,
          total: result.length
        };
      } else {
        const result = data.list.filter(item => item.statflag === true);
        const list = result.slice(
          (pageIndex - 1) * pageSize,
          pageSize * pageIndex
        );
        return {
          code: 20000,
          data: list,
          total: result.length
        };
      }
    }
  }
];
